Skip to content

Introduce arbitrary crate - #1662

Open
shinghim wants to merge 4 commits into
payjoin:masterfrom
shinghim:fuzz
Open

Introduce arbitrary crate#1662
shinghim wants to merge 4 commits into
payjoin:masterfrom
shinghim:fuzz

Conversation

@shinghim

@shinghim shinghim commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

I've written a bunch of arbitrary impls for rust-bitcoin, so I was curious if there's any interest to do it here as well. Those changes haven't been released yet but should be released in rust-bitcoin v0.33 (or whatever the next version is named), and at that point, we will be able to use them to test this crate as well. I've looked through rust-bitcoin to implement all of the types that are used here (Amount, FeeRate, Psbt, etc), so when the new release gets cut, we should be able to add a lot of extensive fuzzing here if we use arbitrary as well.

Note: There's a derive feature, but rust-bitcoin doesn't have it enabled to cut down on dependencies, so I didn't do it here either

Pull Request Checklist

Please confirm the following before requesting review:

@coveralls

coveralls commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 30268078136

Coverage decreased (-0.06%) to 86.429%

Details

  • Coverage decreased (-0.06%) from the base build.
  • Patch coverage: 15 uncovered changes across 1 file (0 of 15 lines covered, 0.0%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
payjoin/src/core/url.rs 15 0 0.0%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 16211
Covered Lines: 14011
Line Coverage: 86.43%
Coverage Strength: 340.42 hits per line

💛 - Coveralls

@shinghim
shinghim marked this pull request as draft June 19, 2026 22:15
@shinghim
shinghim force-pushed the fuzz branch 2 times, most recently from 484d96c to bfae954 Compare June 19, 2026 22:28
@shinghim
shinghim marked this pull request as ready for review June 20, 2026 01:10

@benalleng benalleng left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CACK Looks like a great start. interested to see what kinds of fuzzing we can start using on the state machine with this.

Comment thread fuzz/Cargo.toml Outdated
bench = false

[[bin]]
name = "arbitrary_url"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs to have the full pathname here url_arbitrary_url

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done 👍🏼

@shinghim

Copy link
Copy Markdown
Contributor Author

@benalleng addressed your feedback on the target name. Anything else that needs updating before it's good to go?

@benalleng

Copy link
Copy Markdown
Collaborator

No, sorry I have just been focused on release things lately. I want to make a quick personal fork using the unreleased rust-bitcoin additions + this branch to get a better sense of what arbitrary allows us to do but after that i will be ready to ACK

@shinghim

Copy link
Copy Markdown
Contributor Author

gotcha. I had started down that road a little bit, but a lot of stuff changed in the unreleased version 😆

@benalleng

Copy link
Copy Markdown
Collaborator

General future question - are there plans to create fuzzing around ensuring live and replay paths result in the same session states?

@xstoicunicornx I am hoping that this dep addition will allow us to better fuzz the session states.

@benalleng

benalleng commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

gotcha. I had started down that road a little bit, but a lot of stuff changed in the unreleased version 😆

Ok, I also tried this and ended up spending way too much time trying to patch every dep that relies on old bitcoin versions only to still got stuck. That is a big change... I will scope my test down a bit.

@benalleng benalleng mentioned this pull request Jul 3, 2026
5 tasks
@benalleng benalleng added the fuzz Relating to the payjoin-fuzz crate label Jul 16, 2026
shinghim added 4 commits July 27, 2026 07:56
This crate is used for fuzzing and is the same crate used in
`rust-bitcoin`, which means that we will be able to use the arbitrary
types built in that crate in this one
I moved some of the logic from the existing `decode_url` target into
this one to utilize the fuzzer to test different inputs

@caarloshenriq caarloshenriq left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK

Ran url_arbitrary_url for 30s locally; coverage grew from 430 to 738 without saturating, which is a meaningful improvement over the existing decode_url target.

One thing worth considering in arbitrary_url.rs: append_pair is immediately followed by clear_query, so the URL always exits that branch with an empty query. If the intent is to exercise methods that read a populated query, removing clear_query (or moving it to a separate branch) would cover that path. If the intent is specifically to test clear_query after append_pair, a comment explaining that would help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fuzz Relating to the payjoin-fuzz crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants